<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="js/global_data.js"></script>
<script type="text/javascript" src="backstage/lib/js/jquery.min.js"></script>
<style>
    .loader {
        width: 150px;
        margin: 50px auto 70px;
        margin-top: 30%;
        position: relative;
    }
    .loader .loading-1 {
        position: relative;
        width: 100%;
        height: 10px;
        border: 1px solid #69d2e7;
        border-radius: 10px;
        animation: turn 4s linear 1.75s infinite;
    }
    .loader .loading-1:before {
        content: "";
        display: block;
        position: absolute;
        width: 0%;
        height: 100%;
        background: #69d2e7;
        box-shadow: 10px 0px 15px 0px #69d2e7;
        animation: load 2s linear infinite;
    }
    .loader .loading-2 {
        width: 100%;
        position: absolute;
        top: 10px;
        color: #69d2e7;
        font-size: 22px;
        text-align: center;
        animation: bounce 2s  linear infinite;
    }
    @keyframes load {
        0% {
            width: 0%;
        }
        87.5%, 100% {
            width: 100%;
        }
    }
    @keyframes turn {
        0% {
            transform: rotateY(0deg);
        }
        6.25%, 50% {
            transform: rotateY(180deg);
        }
        56.25%, 100% {
            transform: rotateY(360deg);
        }
    }
    @keyframes bounce {
        0%,100% {
            top: 10px;
        }
        12.5% {
            top: 30px;
        }
    }

</style>
<head>
    <title>Loading...</title>
</head>
<body>
<div class="loader" id="myloader">
    <div class="loading-1"></div>
    <div class="loading-2">Loading...</div>
</div>

</body>
<script>
    // 判断用户有没有登录信息，没有的话自动登录跳转到登录页面
    $.ajax({
        async: false,
        type: "post",
        data:'{"userToken":"'+localStorage.getItem("userToken")+'"}',
        url: serverIpAddress+"User/LodeUserMessage",
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success:function() {
            LodeRobotCode();
        },
        error:function () {
            window.location="login.html";
        }
    });

    function LodeRobotCode() {
        $.ajax({
            async:false,
            type: "post",
            url: serverIpAddress+"CodeGame/LodeRobotCode",
            data:'{"userToken":"'+localStorage.getItem("userToken")+'"}',
            contentType: "application/json;charset=utf-8",
            success: function (data) {
                if(data == "success")
                    window.location = "robot.html";
                else if(data == "fail"){
                    alert("人机代码编译错误，请联系管理员！");
                }
                else { //此处返回字符串"Blocked by Sentinel (flow limiting)"，被Sentinel流控
                    alert("当前是人机对弈模式访问高峰期，请稍后再试");
                }
            }
        });
    }
</script>
</html>
